package com.wsoft.hr.pm.service.impl;

import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wsoft.hr.pm.entity.HrPmMemberTemplateTargetHisEntity;
import com.wsoft.hr.pm.entity.HrPmTargetEntity;
import com.wsoft.hr.pm.manager.HrPmTargetManager;
import com.wsoft.hr.pm.mapper.HrPmMemberTemplateTargetHisMapper;
import com.wsoft.hr.pm.query.template.his.HisInfoQuery;
import com.wsoft.hr.pm.service.IHrPmMemberTemplateTargetHisService;
import com.wsoft.hr.pm.vo.target.TargetVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 人员模版指标历史记录表 服务实现类
 * </p>
 *
 * @author zhanggukai
 * @since 2025年03月01日 14:23:05
 */
@Service
public class HrPmMemberTemplateTargetHisServiceImpl extends ServiceImpl<HrPmMemberTemplateTargetHisMapper, HrPmMemberTemplateTargetHisEntity> implements IHrPmMemberTemplateTargetHisService {

    @Resource
    private HrPmTargetManager targetManager;
    @Override
    public TargetVO getMemberTargetHisInfo(HisInfoQuery query) {
        if(null != query.getId()){
            HrPmMemberTemplateTargetHisEntity targetHisEntity = getById(query.getId());
            return Convert.convert(TargetVO.class, targetHisEntity);
        }
        HrPmTargetEntity targetEntity = targetManager.getById(query.getTargetId());
        return Convert.convert(TargetVO.class, targetEntity);

    }
}
